<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/derek-tags" prefix="dk" %>
<dk:WarPath/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">  

  <head>
    
    <title>修改登陆密码</title>
	<link rel=stylesheet type=text/css href="${_WarPath }/css/global.css"/>
	<script src="${_WarPath }/js/jquery-1.4.js" type="text/javascript"></script>
	<script type="text/javascript" src="js/ct.js"></script>
	<script src="${_WarPath }/jsp/user/login.js" type="text/javascript"></script>
	<script src="${_WarPath }/jsp/user/js/xgmm.js" type="text/javascript"></script>
	<script type="text/javascript" src="js/popupDiv.js"></script>
	
	<script type="text/javascript">
		
		var requestUrl = "/xinlu/user/modifyUserPwdAction.html";
		$(function(){
			
			
			$("#createDymaicCode").bind("click", function(){
				
				
				if(checkForms()){
					
					$.ajax({
				
						url : requestUrl,
						type : "post",
						dataType : "text",
						async:false,
						cache:false,
						data : {
							
							doAction : "getUserDymaicPwd",
							pageId : "modifyUserPwd",
							modifyUsername : $("#username").val()
						},
						error : function(data){
							
							alert('网络发生异常,请重试....');
						},
						success : function(data){
							
							window.location.href = "wjmmMddile_index.jsp";
						}
						
					});
				}
				
			});
		});
		
		
		function checkForms(){
			
			if($.trim($("#username").val()) == ''){
				
				alert('用户名不能为空,请输入用户名!');
				return false;
			}
			
			var flag = true;
			$.ajax({
				url : "/xinlu/checkImg",
				type : "post",
				data : {
					imgcode : $("#imgcode").val()
				},
				async:false,
				cache:false,
				success : function(data){
					
					if(data == 'fail'){
				
						flag = false;
					}
				}
			});
			
			if(!flag){
				
				alert('验证码输入错误，请重新输入。');
				return false;
			}
			
			var usernameExist = true;
			$.ajax({
				
				url : requestUrl,
				type : "post",
				dataType : "text",
				async:false,
				cache:false,
				data : {
					
					doAction : "checkUserExist",
					pageId : "modifyUserPwd",
					modifyUsername : $("#username").val()
				},
				error : function(data){
					alert(data.responseText);
					alert('网络发生异常,请重试....');
				},
				success : function(data){
					
					if(data == "fail"){
						alert('用户名不存在，请确认后再输入！');
						usernameExist = false;
					}else if(data == 'email'){
						
						alert('你没有安全邮箱或邮箱符合格式，请联系客服！');
						usernameExist = false;
					}
				}
				
			});
			
			if(!usernameExist){
				
				
				return false;
			}
			
			return true;
			
		}
		
	</script>
  </head>
  
  <body>
    
 	<table id="tablehovered" class="tableborder" border="0" cellSpacing="1" cellPadding="1" align="center">
		<form method="post" name="form1" action="">
			<tr>
				<th class="pe_right" colSpan="2">
					提示：登陆密码找回
				</th>
			</tr>
			<tr>
				<td class="pe_right" colSpan="2">请输入正确的验证码!!</td>
			</tr>
			<tr>
				<th class="pe_right" colSpan="2">操作：</th>
			</tr>
			<tr>
				<td class="pe_left">
					用户名：
				</td>
				<td class="pe_right">
					<input name="username" id="username" value="" size="30" type="text" />
				</td>
			</tr>
			<tr>
				<td class="pe_left">验证码：</td>
				<td class="pe_right">
					<input name="imgcode" value="" id="imgcode" size="5" type="text" />
					<img src="${_WarPath}/validateCode.gif" />
				</td>
			</tr>
			<tr>
				<td class="pe_right" colspan="2" align="center">
					<input class="button" name="sc" value="生成动态密码" type="button" id="createDymaicCode" />
				</td>
			</tr>
		</form>
</table>


        	<div class="clb"></div>
    
  </body>
</html>
